package nettyDemon;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;

public class Server {

	public static void main(String[] args) throws InterruptedException {
		EventLoopGroup bossGroup = new NioEventLoopGroup();

		EventLoopGroup workerGroup = new NioEventLoopGroup();
		
		try {
			ServerBootstrap serverbootstrap = new ServerBootstrap();

			ChannelFuture channelfuture = //
					serverbootstrap.group(bossGroup, workerGroup)//
							.channel(NioServerSocketChannel.class)//
							.childHandler(new TestServerChannelInitializer())//
							.bind(8899)//
							.sync();//

			channelfuture.channel().closeFuture().sync();
		} finally {
			bossGroup.shutdownGracefully();
			workerGroup.shutdownGracefully();
		}
	}

}
